/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HedgehogPanel.java
 *
 * Created on 7-okt-2009, 20:20:49
 */

package gui;

import flowvis.HedgehogRenderer;

/**
 *
 * @author michel
 */
public class HedgehogRendererPanel extends javax.swing.JPanel {

    HedgehogRenderer renderer;

    /** Creates new form HedgehogPanel */
    public HedgehogRendererPanel(HedgehogRenderer renderer) {
        initComponents();
        this.renderer = renderer;
        visibleCheckbox.setSelected(HedgehogRenderer.getVisible());
        directionColoringCheckbox.setSelected(renderer.getColoring());
        scalingTextfield.setText("" + renderer.getScale());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        visibleCheckbox = new javax.swing.JCheckBox();
        directionColoringCheckbox = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        scalingTextfield = new javax.swing.JTextField();

        visibleCheckbox.setText("Visible");
        visibleCheckbox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visibleCheckboxActionPerformed(evt);
            }
        });

        directionColoringCheckbox.setText("Color by direction");
        directionColoringCheckbox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                directionColoringCheckboxActionPerformed(evt);
            }
        });

        jLabel1.setText("Vector scaling");

        scalingTextfield.setText("jTextField1");
        scalingTextfield.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                scalingTextfieldActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(visibleCheckbox)
                    .addComponent(directionColoringCheckbox)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(scalingTextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(visibleCheckbox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(directionColoringCheckbox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(scalingTextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(217, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void visibleCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visibleCheckboxActionPerformed
        HedgehogRenderer.setVisible(visibleCheckbox.isSelected());
    }//GEN-LAST:event_visibleCheckboxActionPerformed

    private void directionColoringCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_directionColoringCheckboxActionPerformed
        renderer.setColoring(directionColoringCheckbox.isSelected());
    }//GEN-LAST:event_directionColoringCheckboxActionPerformed

    private void scalingTextfieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scalingTextfieldActionPerformed
        renderer.setScale(Float.parseFloat(scalingTextfield.getText()));
    }//GEN-LAST:event_scalingTextfieldActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox directionColoringCheckbox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField scalingTextfield;
    private javax.swing.JCheckBox visibleCheckbox;
    // End of variables declaration//GEN-END:variables

}
